package com.dong;

/**
 * Created by dongwang
 * on 10/07/2018.
 */
public class SomeSingleton {
    private static boolean isInitialized = false;

    private SomeSingleton() {
        synchronized (SomeSingleton.class) {
            if (!isInitialized) {
                isInitialized = true;
            } else {
                throw new RuntimeException("invalid way create new [com.dong.SomeSingleton] instance!");
            }
        }
    }

    private static class SomeSingletonInstanceModel {
        private static final SomeSingleton INSTANCE = new SomeSingleton();
    }

    public static SomeSingleton getSingletonInstance() {
        return SomeSingletonInstanceModel.INSTANCE;
    }
}
